package IO;

import java.io.FileOutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/*简单的记事本工具
* 要求：
*   程序启动后将用户在控制台输入的每一行字母串写入到文件note。txt
*   直到用户输入exit时程序退出
*   不用考虑换行问题*/
public class TestNote {
    public static void main(String[] args)throws Exception {
        Scanner scanner = new Scanner(System.in);
        FileOutputStream fileOutputStream = new FileOutputStream("note.txt");
        String lin = scanner.nextLine();
        int i =1;
        while (!"exit".equals(lin)){
            String x = i+lin+"\n";
            fileOutputStream.write(x.getBytes(StandardCharsets.UTF_8));
            lin = scanner.nextLine();
            i++;
        }
        System.out.println("输入结束");
        fileOutputStream.close();
    }
}
